package cn.wizzer.app.user.modules.models;


import cn.wizzer.app.user.modules.models.enums.RedPacketStatusEnum;
import cn.wizzer.app.user.modules.models.enums.RedPacketTypeEnum;
import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 红包
 */
@Data
@Table("red_packet")
public class RedPacket extends BaseModel implements Serializable {
    @Column
    @Name
    @Comment("ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    @PrevInsert(els = {@EL("uuid()")})
    private String id;

    @Column
    @Comment("编号")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String no;

    @Column
    @Comment("用户ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String userId;

    @Comment("币种ID")
    @Column
    @ColDefine(type = ColType.VARCHAR, width = 32, notNull = true)
    private String currencyId;

    @Comment("红包类型 Random 随机 Identical 固定")
    @Column
    @ColDefine(type = ColType.VARCHAR, width = 16, notNull = true)
    private RedPacketTypeEnum type;

    /**
     * 红包个数不能超过100个
     */
    @Comment("红包个数")
    @Column
    @ColDefine(type = ColType.INT, width = 16)
    private Integer quantity;

    @Column
    @Comment("红包总额")
    @ColDefine(type = ColType.FLOAT, width = 16, precision = 6)
    private BigDecimal total;

    @Column
    @Comment("已被领取总额")
    @ColDefine(type = ColType.FLOAT, width = 16, precision = 6)
    private BigDecimal opened = BigDecimal.ZERO;

    @Comment("红包祝福语")
    @Column
    @ColDefine(type = ColType.VARCHAR, width = 32, notNull = true)
    private String wish;

    /**
     * 发出红包默认状态是领取中，超过24小时就变成已过期
     */
    @Column
    @Comment("状态-> opening:领取中,opened:领取完，expired:已过期 ")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private RedPacketStatusEnum status;

    @Column
    @Comment("创建时间")
    @PrevInsert(els = @EL("$me.now()"))
    private Long ctAt;


}
